/*
 * File:   parsolver.cpp
 * Author: tomas
 *
 * Created on May 3, 2009, 5:34 PM
 */

#include <stdlib.h>

#include <boost/mpl/and.hpp>

#include <iostream>
#include <fstream>

#include "ParStack.h"
#include "Instance.h"
#include "instancereader.h"

#include "parSolver.h"

const bool DEBUG = false;


int main(int argc, char** argv) {

    
    mpi::environment env(argc, argv);
    mpi::communicator world;

	if (world.rank() == 0)
	{
		utils::log("Starting with params:");
		for (unsigned i = 0; i!=argc; ++i)
		{
			utils::log(argv[i]);
		}
	}
	if (argc != 2)
	{
		std::cout << "Pouziti:\n  ParSolver nazevsouboru" << std::endl;
		exit(EXIT_FAILURE);
	}
	
	std::ifstream instream(argv[1]);

	utils::masterPrint(utils::toString("opening ", argv[1]));


    InstanceReader rdr = InstanceReader(instream);
    Instance inst = rdr.readInstance();

    instream.close();

    ParSolver s(inst, &env, &world);
    Solution sol = s.solve();

    if(world.rank() == 0) {
        std::cout << "reseni:" << std::endl;
        std::cout << sol << std::endl;
    }

    return (EXIT_SUCCESS);
}


